package FulbitoFacil.Servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import FulbitoFacil.excepcion.DAOExcepcion;
import FulbitoFacil.negocio.GestionAlquiler;

/**
 * Servlet implementation class InsertarAlquilerServlet
 */
@WebServlet("/InsertarAlquilerServlet")
public class InsertarAlquilerServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public InsertarAlquilerServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	
		String nomCancha = request.getParameter("textcancha");
		String diaAlquil = request.getParameter("textdia");
		String horaAlq = request.getParameter("texthora");
		PrintWriter out = response.getWriter();
	
		out.println(nomCancha);
		out.println(diaAlquil);
		out.println(horaAlq);
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	/*	System.out.println("123");
		String nomCancha = request.getParameter("textcancha");
		String diaAlquil = request.getParameter("textdia");
		String horaAlq = request.getParameter("texthora");
		PrintWriter out = response.getWriter();
	
		out.println(nomCancha);
		out.println(diaAlquil);
		out.println(horaAlq);*/
		//GestionAlquiler NegAlqui = new GestionAlquiler();

	//HttpSession sesion = request.getSession();
		/*try {
			String ms = "";
			ms = NegAlqui.insertarAlquiler(nomCancha, diaAlquil, horaAlq);

			 response.sendRedirect(request.getContextPath() + "/comentarioCancha.jsp");
			 response.sendRedirect(request.getContextPath() + "/ListadoSala.jsp");
			 request.getSession().setAttribute("msg", ms);
			 request.getSession().setAttribute("ruta", "RegistrarCancha.jsp");
			 RequestDispatcher rd =
			 request.getRequestDispatcher("/mensaje.jsp");
			 rd.forward(request, response);
		} catch (DAOExcepcion e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
	
	
	}

}
